package model
{
	import mx.collections.ArrayCollection;
	
	[Bindable]
	public class ContentModel
	{
		[Bindable]
		public var artistsData:ArrayCollection=new ArrayCollection();
		
		[Bindable]
		public var albumsData:ArrayCollection=new ArrayCollection();
		
		[Bindable]
		public var albumsArtistsConnectionsData:ArrayCollection = new ArrayCollection();

		private static var instance:ContentModel;

		public function ContentModel()
		{
			instance=this;
		}

		public static function getInstance():ContentModel
		{
			if (instance == null)
			{
				instance=new ContentModel();
			}
			return instance;
		}
		
		public function getListOfAlbumsAsociatedWithArtist(artistId:int):ArrayCollection {
			var result:ArrayCollection = new ArrayCollection();
			for each(var item:Object in albumsArtistsConnectionsData){
				if(item.artistId != artistId){
					continue;
				} 
				for each(var albumItem in albumsData){
					if(albumItem.id == item.albumId){
						result.addItem(albumItem);
					}
				}
			}
			return result;
		}
		
	}
}
